package steveshrader.budget.domain;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;

import steveshrader.budget.server.BudgetService;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class PaymentType {
        private Long id;

        @PrimaryKey        
        @Persistent
        private String name;
                
    	@NotNull
    	@DecimalMin("0")
    	private Integer version = 0;

        public PaymentType() {
        }

        public PaymentType(String name) {
            this.name = name;
        }

    	public static PaymentType findPaymentType(Long id) {
    		return BudgetService.findPaymentType(id);
    	}

        public String getName() {
                return name;
        }

        public Long getId() {
                return id;
        }
        
    	public Integer getVersion() {
    		return version;
    	}
}